import React, { Component } from "react";

export default class App extends Component {
  state = {
    myname: "klzq",
  };
  render() {
      console.log("是否触发");
    return (
      <div>
        <div
          id="name"
          style={{ height: "30px", backgroundColor: "red", overflow: "hidden" }}
        >
          <button
            onClick={() => {
              this.setState({ myname: "name修改了" });
            }}
          >
            点击查看生命周期
          </button>
          {this.state.myname}
        </div>
      </div>
    );
  }
  shouldComponentUpdate(nextprops,nextstate){
     //false 停止更新  两个形参是最新的
    //   this.state是老的状态
    // if(nextprops.myname !== this.state.myname){
    //     return true
    // }
    if(JSON.stringify(this.state) !== JSON.stringify(nextstate)){
        return true
    }
    return false
  }
}
